﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.Data.Activation;
using StyleMVVM.DependencyInjection;

namespace StyleMVVM.Data.Transform
{
	internal class CompiledTransformStrategyHelper
	{
		public static T DeepCloneIntoInstance<T>(IActivationService activationService, T cloneObject, T cloneInto)
		{
			return (T)activationService.DeepCloneIntoInstance(cloneObject, cloneInto);
		}

		public static T Create<T>(IActivationService activationService)
		{
			return (T)activationService.CreateByType(Bootstrapper.Instance.Container.CreateInjectionContext(), typeof(T));
		}

		public static object GetPropertyValue(IReflectionService reflectionService, object target, string propertyName)
		{
			return reflectionService.GetPropertyValue(target, propertyName);
		}

		public static void SetPropertyValue(IReflectionService reflectionService,
		                                    object target,
		                                    string propertyName,
		                                    object newValue)
		{
			reflectionService.SetPropertyValue(target, propertyName, newValue);
		}

		public static TOut Transform<TIn, TOut>(ITransformService transformService,
		                                        TIn tIn,
		                                        bool allowErrors,
		                                        bool looseTransform)
		{
			return (TOut)transformService.Transform(tIn, typeof(TOut), allowErrors, looseTransform);
		}
	}
}